package com.cloud.service.impl;

import com.cloud.entity.Admin;
import com.cloud.mapper.AdminMapper;
import com.cloud.service.AdminService;
import com.cloud.utils.Md5Tools;
import org.springframework.stereotype.Service;

/**
 * @author .
 * created in 2020/1/11 11:24
 */

@Service
public class AdminServiceImpl implements AdminService {

    private AdminMapper adminMapper;

    public AdminServiceImpl(AdminMapper adminMapper) {
        this.adminMapper = adminMapper;
    }

    @Override
    public Admin findAdminByNameAndPwd(String name, String pwd) {
        Admin admin = adminMapper.findByNameAndPwd(name);
        if (admin != null && admin.getPassword().equals(Md5Tools.numberMd5(pwd))) {
            return admin;
        }
        return null;
    }

}
